package com.gateway.register.common.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gateway.register.common.type.DataType;
import com.gateway.register.common.type.DataTypeParent;

/**
 * @program: api-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2023/2/12 21:46
 **/
public class RouteRegisterDTO implements DataTypeParent {

    /**
     * 当前应用id
     */
    private String appId;

    /**
     * 服务id(默认为项目名称spring.application.name)
     */
    private String serviceId;

    /**
     * 应用名
     */
    private String appName;

    /**
     * 类型
     */
    private String rpcType;

    /**
     * 上下文路径
     */
    private String contextPath;

    /**
     * 环境变量
     */
    private String env;

    /**
     * ip 地址
     */
    private String host;

    /**
     * 端口号
     */
    private Integer port;


    @Override
    @JsonIgnore
    public DataType getType() {
        return DataType.ROUTE;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getRpcType() {
        return rpcType;
    }

    public void setRpcType(String rpcType) {
        this.rpcType = rpcType;
    }

    public String getContextPath() {
        return contextPath;
    }

    public void setContextPath(String contextPath) {
        this.contextPath = contextPath;
    }

    public String getEnv() {
        return env;
    }

    public void setEnv(String env) {
        this.env = env;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }


    public static final class Builder {
        private String appId;
        private String serviceId;
        private String appName;
        private String rpcType;
        private String contextPath;
        private String env;
        private String host;
        private Integer port;

        private Builder() {
        }

        public static Builder builder() {
            return new Builder();
        }

        public Builder appId(String appId) {
            this.appId = appId;
            return this;
        }

        public Builder serviceId(String serviceId) {
            this.serviceId = serviceId;
            return this;
        }

        public Builder appName(String appName) {
            this.appName = appName;
            return this;
        }

        public Builder rpcType(String rpcType) {
            this.rpcType = rpcType;
            return this;
        }

        public Builder contextPath(String contextPath) {
            this.contextPath = contextPath;
            return this;
        }

        public Builder env(String env) {
            this.env = env;
            return this;
        }

        public Builder host(String host) {
            this.host = host;
            return this;
        }

        public Builder port(Integer port) {
            this.port = port;
            return this;
        }

        public RouteRegisterDTO build() {
            RouteRegisterDTO routeRegisterDTO = new RouteRegisterDTO();
            routeRegisterDTO.setAppId(appId);
            routeRegisterDTO.setServiceId(serviceId);
            routeRegisterDTO.setAppName(appName);
            routeRegisterDTO.setRpcType(rpcType);
            routeRegisterDTO.setContextPath(contextPath);
            routeRegisterDTO.setEnv(env);
            routeRegisterDTO.setHost(host);
            routeRegisterDTO.setPort(port);
            return routeRegisterDTO;
        }
    }
}
